@MobileTen Since my answer is long, I replied to the post .
Post
Replies
Boosts
Views
Activity
@MobileTen what do you mean by "Is the value media or Media?" I created a class called MediaManager.
There is no build errors or anything.
There is no issue on Xcode 14.2 but for some reason on Xcode 14.3.1 or later, Apple's MediaPlayer framework could not find MPMusicPlayerPlayParameters and results crash while launching the app. I guess MediaPlayer framework is a dynamic framework and that is the reason why it fails on Run Time.
Following iOS versions are affected; 16.0, 16.1 and 16.2. (I couldn't test on iOS 16.3 or iOS 15)
However it doesn't crash on iOS 16.4 or later.
I checked the link and here is how I get the dictionary:
import MusicKit
import MediaPlayer
/// ...
var tracksInQueue: MPMusicPlayerPlayParametersQueueDescriptor = .init(playParametersQueue: [])
/// ...
func getPlayParameters(from playParameters: PlayParameters?) -> MPMusicPlayerPlayParameters? {
guard let playParameters = playParameters,
let data = try? JSONEncoder().encode(playParameters),
let playParameters = try? JSONDecoder().decode(MPMusicPlayerPlayParameters.self, from: data) else {
return nil
}
return playParameters
}
func prepareQueue() {
DispatchQueue.global(qos: .utility).async { [weak self] in
guard let self else {
return
}
self.tracksInQueue = MPMusicPlayerPlayParametersQueueDescriptor(playParametersQueue: self.tracks.compactMap {
self.mediaManager.getPlayParameters(from: $0.playParameters)
})
self.tracksInQueue.startItemPlayParameters = self.tracksInQueue.playParametersQueue.first
// queue is ready will be played when user presses the play button
}
/// ...
}
Actually today I tried to remove a track from the playlist, as far as I know you can only do it with (MusicLibrary.shared.edit) but It only works if the playlist is created by your app. If I try to delete a playlist that I created on Music or any other app, it gives an error with the similar description that I just mentioned.
I receive the following error:
Error Domain=MPErrorDomain Code=5 "The requested action is not supported" UserInfo={NSLocalizedDescription=The requested action is not supported}
The Error that I am receiving is:
Error Domain=MPErrorDomain Code=5 "The requested action is not supported" UserInfo={NSLocalizedDescription=The requested action is not supported}
The error that I am receiving is:
Domain=MPErrorDomain Code=5 "The requested action is not supported" UserInfo={NSLocalizedDescription=The requested action is not supported}